#ifndef __TIMER_H__
#define __TIMER_H__

#include <functional>

class Timer
{
public:
    typedef std::function<void()> Callback;

    Timer(Callback cb, int initialTime, int intervalTime);
    ~Timer() {}

    void start();
    void stop();

private:
    int createTimerfd();

    void setTimerfd(int, int);

    void handleRead();

private:
    int fd_;
    Callback cb_;
    int initialTime_;
    int intervalTime_;
};

#endif
